package com.sec.android.app.calculator;

import android.os.Handler;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.EditText;
import com.sec.android.widgetapp.calculator.Panel;
import com.sec.android.widgetapp.calculator.Panel.OnPanelListener;

class EventListener
  implements View.OnClickListener, View.OnLongClickListener, Panel.OnPanelListener
{
  private static String disText;
  int equal;
  int[] historyCount = new int[10];
  boolean mCheck = false;
  EditText mDisplay;
  EventHandler mHandler;
  EditText mHisScreen;
  History mHistory;
  Panel mPanel;
  boolean mdisCheck = false;
  private StringBuilder sb = new StringBuilder();

  private void clearSB()
  {
    int i = this.sb.length();
    if (i == 0);
    while (true)
    {
      return;
      this.sb.delete(0, i);
    }
  }

  public void onClick(View paramView)
  {
    this.mHandler.setFrontText(this.mHandler.getText());
    switch (paramView.getId())
    {
    default:
    case 2130968605:
    case 2130968586:
    case 2130968589:
    case 2130968601:
    case 2130968603:
    case 2130968604:
    case 2130968614:
    case 2130968618:
    case 2130968602:
    case 2130968598:
    case 2130968599:
    case 2130968600:
    case 2130968594:
    case 2130968595:
    case 2130968596:
    case 2130968590:
    case 2130968591:
    case 2130968592:
    case 2130968597:
    case 2130968593:
    case 2130968588:
    case 2130968587:
    case 2130968606:
    case 2130968607:
    case 2130968608:
    case 2130968609:
    case 2130968613:
    case 2130968611:
    case 2130968610:
    case 2130968612:
    case 2130968615:
    case 2130968616:
    case 2130968617:
    case 2130968619:
    case 2130968620:
    }
    while (true)
    {
      if (this.sb.length() > 0)
        this.mHandler.insert(this.sb);
      this.mHandler.setSelecting(false);
      clearSB();
      this.mDisplay.setSelection(this.mHandler.getTextLength());
      return;
      this.mHandler.onEnter();
      continue;
      this.mHandler.onClear();
      continue;
      this.mHandler.onBackspace();
      continue;
      this.mHandler.onParenthesis();
      continue;
      this.mHandler.onDecimal();
      continue;
      this.mHandler.onPlusMinus();
      continue;
      this.mHandler.onFraction();
      continue;
      this.mHandler.onAbs();
      continue;
      this.sb.append("0");
      continue;
      this.sb.append("1");
      continue;
      this.sb.append("2");
      continue;
      this.sb.append("3");
      continue;
      this.sb.append("4");
      continue;
      this.sb.append("5");
      continue;
      this.sb.append("6");
      continue;
      this.sb.append("7");
      continue;
      this.sb.append("8");
      continue;
      this.sb.append("9");
      continue;
      this.sb.append("+");
      continue;
      this.sb.append("-");
      continue;
      this.sb.append("×");
      continue;
      this.sb.append("÷");
      continue;
      this.sb.append("√(");
      continue;
      this.sb.append("%");
      continue;
      this.sb.append("!");
      continue;
      this.sb.append("sin(");
      continue;
      this.sb.append("tan(");
      continue;
      this.sb.append("cos(");
      continue;
      this.sb.append("log(");
      continue;
      this.sb.append("ln(");
      continue;
      this.sb.append("e^(");
      continue;
      this.sb.append("^(2)");
      continue;
      this.sb.append("^(");
      continue;
      this.sb.append("π");
      continue;
      this.sb.append("e");
    }
  }

  public boolean onLongClick(View paramView)
  {
    this.mHandler.setSelecting(false);
    if (paramView.getId() != 2130968589);
    for (int i = 0; ; i = 1)
    {
      return i;
      this.mHandler.handler.sendEmptyMessage(0);
    }
  }

  public boolean onPanelClicked(Panel paramPanel)
  {
    this.mHandler.setSelecting(false);
    this.mHandler.setLongClick(false);
    if (!this.mPanel.isOpen())
      this.mPanel.setAniEnd(false);
    for (int i = 1; ; i = 0)
    {
      return i;
      if ((this.mHandler.isDisplayScreen()) || (this.mHandler.isHistoryScreen()))
        break;
    }
  }

  public void onPanelClosed(Panel paramPanel)
  {
    this.mHandler.setSelecting(false);
    this.mHandler.setLongClick(false);
    this.mHandler.goneCursor();
    disText = this.mDisplay.getText().toString();
    String str1 = disText.replace("\n", "");
    this.equal = str1.indexOf("=");
    int i = 0;
    StringBuilder localStringBuilder;
    int j;
    if (str1.length() != 0)
    {
      if (this.mHistory.mPos == 10)
        i = 1;
      if (this.mHandler.isCheckResult())
      {
        str1 = "";
        localStringBuilder = new StringBuilder();
        j = i;
        label105: if (j >= this.mHistory.mPos)
          break label230;
        localStringBuilder.append(this.mHistory.current(j).getBase());
        localStringBuilder.append("\n=");
        localStringBuilder.append(this.mHistory.current(j).getEdited());
        if (j != this.mHistory.mPos - 1)
          break label222;
      }
    }
    label222: for (String str3 = ""; ; str3 = "\n\n")
    {
      localStringBuilder.append(str3);
      j++;
      break label105;
      if (this.equal == -1)
        break;
      str1 = str1.substring(0, this.equal);
      break;
      str1 = "";
      break;
    }
    label230: String str2;
    int k;
    EditText localEditText;
    if (str1.length() != 0)
    {
      if (localStringBuilder.length() == 0)
      {
        str2 = "";
        localStringBuilder.append(str2);
        localStringBuilder.append(str1);
      }
    }
    else
    {
      this.mHisScreen.setText(this.mHandler.changeColor(localStringBuilder));
      this.mDisplay.setVisibility(8);
      this.mHisScreen.setVisibility(0);
      k = this.mHisScreen.getText().length();
      localEditText = this.mHisScreen;
      if (k != 0)
        break label349;
    }
    label349: for (int m = 0; ; m = k)
    {
      localEditText.setSelection(m);
      this.mHisScreen.requestFocus();
      return;
      str2 = "\n\n";
      break;
    }
  }

  public void onPanelClosedForConfig()
  {
    this.mHandler.setSelecting(false);
    this.mHandler.setLongClick(false);
    this.mHandler.goneCursor();
    String str1 = this.mDisplay.getText().toString().replace("\n", "");
    this.equal = str1.indexOf("=");
    int i = 0;
    StringBuilder localStringBuilder;
    int j;
    if (str1.length() != 0)
    {
      if (this.mHistory.mPos == 10)
        i = 1;
      if (this.mHandler.isCheckResult())
      {
        str1 = "";
        localStringBuilder = new StringBuilder();
        j = i;
        label98: if (j >= this.mHistory.mPos)
          break label219;
        localStringBuilder.append(this.mHistory.current(j).getBase());
        localStringBuilder.append("\n=");
        localStringBuilder.append(this.mHistory.current(j).getEdited());
        if (j != this.mHistory.mPos - 1)
          break label211;
      }
    }
    label211: for (String str3 = ""; ; str3 = "\n\n")
    {
      localStringBuilder.append(str3);
      j++;
      break label98;
      if (this.equal == -1)
        break;
      str1 = str1.substring(0, this.equal);
      break;
      str1 = "";
      break;
    }
    label219: String str2;
    int k;
    EditText localEditText;
    if (str1.length() != 0)
    {
      if (localStringBuilder.length() == 0)
      {
        str2 = "";
        localStringBuilder.append(str2);
        localStringBuilder.append(str1);
      }
    }
    else
    {
      this.mHisScreen.setText(this.mHandler.changeColor(localStringBuilder));
      this.mDisplay.setVisibility(8);
      this.mHisScreen.setVisibility(0);
      k = this.mHisScreen.getText().length();
      localEditText = this.mHisScreen;
      if (k != 0)
        break label334;
    }
    label334: for (int m = 0; ; m = k)
    {
      localEditText.setSelection(m);
      this.mHisScreen.requestFocus();
      return;
      str2 = "\n\n";
      break;
    }
  }

  public void onPanelOpened(Panel paramPanel)
  {
    this.mHandler.setSelecting(false);
    this.mHandler.setLongClick(false);
    this.mHandler.goneCursor();
    int i = this.mHandler.getCursor(this.mDisplay, true);
    int j = this.mHandler.getCursor(this.mDisplay, false);
    this.mHisScreen.setVisibility(8);
    this.mDisplay.setVisibility(0);
    this.mHisScreen.setText("");
    this.mPanel.setAniEnd(true);
    if (i != j)
    {
      this.mDisplay.setSelection(i, j);
      this.mHandler.showCursor();
      if (j == this.mHandler.getTextLength())
        this.mHandler.setSelecting(true);
    }
    while (true)
    {
      this.mDisplay.requestFocus();
      return;
      this.mDisplay.setSelection(this.mDisplay.getText().length());
    }
  }

  void setHandler(EventHandler paramEventHandler, Panel paramPanel, EditText paramEditText1, EditText paramEditText2, History paramHistory)
  {
    this.mHandler = paramEventHandler;
    this.mPanel = paramPanel;
    this.mHistory = paramHistory;
    this.mHisScreen = paramEditText2;
    this.mDisplay = paramEditText1;
    this.mDisplay.setRawInputType(0);
    this.mHisScreen.setRawInputType(0);
  }
}

/* Location:           C:\Development\Android_Java_C\Workspace\TouchWizCalculator\TouchWizCalculator_dex2jar.jar
 * Qualified Name:     com.sec.android.app.calculator.EventListener
 * JD-Core Version:    0.6.0
 */